package com.jhuster.jnote;

import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.net.Socket;

public class UserActivity extends AppCompatActivity {


    private EditText _emailText;
    private EditText _nameText;
    private Button _logoutButton;
    private TextView _changePasswordLink;



    //声明一个SharedPreferences对象和一个Editor对象
    private SharedPreferences preferences;
    private SharedPreferences.Editor editor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user);


        _emailText = (EditText) findViewById(R.id.email);
        _nameText = (EditText) findViewById(R.id.name);
        _logoutButton = (Button) findViewById(R.id.btn_logout);
        _changePasswordLink = (TextView) findViewById(R.id.change_password);


        String name = preferences.getString("email", null);
        if (name == null) {
            //checkBox.setChecked(false);
        } else {
            _emailText.setText(name);

        }


        _logoutButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(intent);//跳转到登录界面

            }
        });

        _changePasswordLink.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(intent);//打开修改密码界面，修改成功后跳转到登录界面

            }
        });
    }

    private Thread newThread;         //声明一个子线程
    static Socket client;
    public void getUserInfomation(){
        String email = _emailText.getText().toString();



    }



}
